package cn.skyquant.quant4j.service.boot.model.goods;

import cn.skyquant.quant4j.api.enums.BorkerType;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Optional;

@Repository
public interface GoodsRepository extends CrudRepository<Goods, Integer> {

    List<Goods> findByBorkerType(BorkerType borkerType);

    List<Goods> findBySymbol(String symbol);

    @Query("select u from Goods u where u.symbol = ?1 and u.borkerType=?2")
    Optional<Goods> getBySymbolAndBorkerType(String symbol, BorkerType borkerType);

    @Query("select u from Goods u where u.symbol like %?1% and u.borkerType=?2")
    List<Goods> findBySymbolAndBorkerType(String symbol,BorkerType borkerType);

}
